app.service("uploadService", function ($http) {

    this.upload = function () {

        var forData = new FormData();
        forData.append("file", file.files[0]);

        return $http({
            method: 'POST',
            url: '/tanhaogongManager/company/upLoadContract',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };

    this.uploadChannelUserContract = function () {

        var forData = new FormData();
        forData.append("file", file.files[0]);

        return $http({
            method: 'POST',
            url: '/tanhaogongManager/channelUser/upLoadContract',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };

    this.uploadSchedulingVoucher = function () {

        var forData = new FormData();
        forData.append("file", file.files[0]);

        return $http({
            method: 'POST',
            url: '/tanhaogongManager/extractRecord/uploadSchedulingVoucher',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };


    this.uploadBusinessLicense = function () {

        var forData = new FormData();
        forData.append("file", file_business_license.files[0]);
        return $http({
            method: 'POST',
            url: '/tanhaogongManager/company/uploadBusinessLicense',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };

    //上传任务确认函
    this.uploadConfirmLetter_two = function () {

        var forData = new FormData();
        forData.append("file", file.files[0]);

        return $http({
            method: 'POST',
            url: '/tanhaogongManager/task/uploadConfirmLetter',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };


    this.uploadFrontIdCard = function () {

        var forData = new FormData();
        forData.append("file", file_front.files[0]);

        return $http({
            method: 'POST',
            url: '/tanhaogongManager/user/uploadFrontIdCard',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };
    this.uploadBackIdCard = function () {

        var forData = new FormData();
        forData.append("file", file_back.files[0]);

        return $http({
            method: 'POST',
            url: '/tanhaogongManager/user/uploadBackIdCard',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };

    this.uploadUserBusinessLicense = function () {
        var forData = new FormData();
        forData.append("file", user_business_license.files[0]);
        return $http({
            method: 'POST',
            url: '/tanhaogongManager/user/uploadBusinessLicense',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };

    this.uploadFrontIdCard_companyName = function () {

        var forData = new FormData();
        forData.append("file", file_front.files[0]);

        return $http({
            method: 'POST',
            url: '/tanhaogongManager/company/uploadFrontIdCard',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };
    this.uploadBackIdCard_companyName = function () {

        var forData = new FormData();
        forData.append("file", file_back.files[0]);

        return $http({
            method: 'POST',
            url: '/tanhaogongManager/company/uploadBackIdCard',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };

    this.uploadTaxInfoBusinessLicense = function () {
        var forData = new FormData();
        forData.append("file", tax_bl_file.files[0]);
        return $http({
            method: 'POST',
            url: '/tanhaogongManager/taxInfo/uploadBusinessLicense',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };

    this.uploadTaxInfoEntrustmentQualification = function () {
        var forData = new FormData();
        forData.append("file", tax_eq_file.files[0]);
        return $http({
            method: 'POST',
            url: '/tanhaogongManager/taxInfo/uploadQualification',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };

    this.uploadPaperContract = function () {
        var forData = new FormData();
        forData.append("file", user_paper_contract.files[0]);
        return $http({
            method: 'POST',
            url: '/tanhaogongManager/user/uploadPaperContract',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };

    this.uploadInvoiceExamples = function (params) {
        let forData = new FormData();
        const uploadsFile = document.getElementById(`invoice_example_file${params.type}`);
        forData.append("file", uploadsFile.files[0]);
        forData.append("type", params.type);
        forData.append("taxInfoId", params.taxInfoId);
        return $http({
            method: 'POST',
            url: '/tanhaogongManager/taxInfo/uploadInvoiceExamples',
            data: forData,
            headers: {'content-Type': undefined},
            transformRequest: angular.identity
        });
    };
});